package cn.bb.springboothello.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

@RestController   //该类下所有的所有返回数据都会自动转换为json    等同于@Controller   @ResponseBody
public class FileUploadController {
    /*处理文件上传*/
    @RequestMapping("/fileUploadController")
    public Map<String,Object> fileupload(MultipartFile fileupload) throws Exception{
        System.out.println("上传图片的名称："+fileupload.getOriginalFilename());
        fileupload.transferTo(new File("E:/"+fileupload.getOriginalFilename()));
        Map<String,Object> map=new HashMap<>();
        map.put("msg","ok");
        return map;
    }
}
